import os
import subprocess

def activate_conda_env(env_name):
    # 构建激活环境的命令
    command = f"source /Pub/Users/wangyk/miniconda3/bin/activate {env_name} && env"
    
    # 使用 subprocess.run 执行命令并捕获输出
    result = subprocess.run(command, capture_output=True, text=True, shell=True, executable="/bin/bash")
    
    if result.returncode != 0:
        print(f"Error activating conda environment: {result.stderr}")
        return
    
    # 解析环境变量
    env_vars = result.stdout.splitlines()
    for var in env_vars:
        key, value = var.split("=", 1)
        os.environ[key] = value
        print(value)
        
activate_conda_env("/Pub/Users/wangyk/miniconda3/envs/pyscenic")
os.system(f"\n\necho $PATH")

